﻿#include <RinexFileReader/Formatter.h>
#include <RinexFileReader/RinexFile.h>

#include <cassert>
#include <fstream>
#include <iostream>
#include <print>
#include <ranges>

int main(int argc, char* argv[])
{
    std::string files = TESTS;
    for (const auto str : std::views::split(files, '|'))
    {
        std::string filepath(str.begin(), str.end());
        std::ifstream s(filepath, std::ios::binary);

        std::istreambuf_iterator<char> beg(s), end;
        std::string str(beg, end);
        auto result = Rinex::RindexFile::parse(str);
        if (!result)
        {
            std::println("load rinex file failed:{}\n{}", filepath, result.error());
        }
        else
        {
            std::println("load rinex file success:{}", filepath);
            std::visit([](const auto& file) { std::println("{}", file); }, *result);
        }
    }
    return 0;
}